﻿using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace IceCS.Helpers
{
    /// <summary>
    /// 
    /// </summary>
    public class HtmlHelper
    {
        /// <summary>
        /// 转换html为纯文本
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        public string ConvertHtml2PlainText(string html)
        {
            if (string.IsNullOrWhiteSpace(html))
            {
                return string.Empty;
            }
            html = Regex.Replace(html, "(<.+?>|\n)*", "");
            html = Regex.Replace(html, "&\\w+;", "");
            html = Regex.Replace(html, "&#\\w+;", "");
            return html;
        }
    }
}
